//
//  AboutUSVC.m
//  Doctor
//
//  Created by 阳光 on 16/9/11.
//  Copyright © 2016年 阳光. All rights reserved.
//  关于我们界面

#import "AboutUSVC.h"
#import "ServiceVC.h"

@interface AboutUSVC ()<UIScrollViewDelegate>

@property(nonatomic,strong)UIScrollView *scrollView;

@property(nonatomic,strong)UIView *mainView;

@end



@implementation AboutUSVC

- (void)viewDidLoad
{
    [super viewDidLoad];
   
    self.title = NSLocalizedString(@"About Us", nil);//@"关于我们";
    
    [self initNavBarBtnItem];
    
    [self initScrollView];
    
}

-(void)initScrollView
{
    _scrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(0,0,APPW,APPH-64)];
    _scrollView.backgroundColor=WhiteColor;
    _scrollView.delegate=self;
    _scrollView.scrollEnabled=YES;
    _scrollView.userInteractionEnabled=YES;
    _scrollView.showsVerticalScrollIndicator=NO;
    [self.view addSubview:_scrollView];
    
    _mainView=[self setMainView];
    setViewCoord_Y(_mainView,0);
    [_scrollView addSubview:_mainView];
    _scrollView.contentSize=CGSizeMake(APPW,CGRectGetMaxY(self.mainView.frame));
    
}

#define cellH   kmargin*5
-(UIView *)setMainView
{
    UIView *mainView=[[UIView alloc]initWithFrame:CGRectMake(0,0,APPW,0)];
    mainView.backgroundColor=WhiteColor;
    
    UIView *topLine=[UIView new];
    [mainView addSubview:topLine];
    [topLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.size.mas_equalTo(CGSizeMake(APPW,1));
    }];
    topLine.backgroundColor=MAIN_BACK_COLOR;
    setViewHeight_Add(mainView,1);
    
   /***** Logo *****/
    UIImageView *logoUrl=[[UIImageView alloc]initWithFrame:CGRectMake((APPW-80)/2,kmargin*3,80,80)];
    [mainView addSubview:logoUrl];
    logoUrl.image=[UIImage imageNamed:@"logo_aboutus"];
    setViewHeight_Add(mainView,80+kmargin*3);
    
    // 版本号
    UILabel *versionLabel=[mainView getLabelWithText:[NSString stringWithFormat:@"%@ V %@",NSLocalizedString(@"GuGu Doctor", nil),[[[NSBundle mainBundle]infoDictionary]objectForKey:@"CFBundleShortVersionString"]] font:Font_Number(16) textColor:Color666666 textAlignment:NSTextAlignmentCenter lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];//呱呱试管
    [mainView addSubview:versionLabel];
    versionLabel.frame=CGRectMake((APPW-300)/2,mainView.frame.size.height+kmargin,300,kmargin*3);
    setViewHeight_Add(mainView,kmargin*4);
    
    // 呱呱试管简介
    NSString *profileStr = NSLocalizedString(@"Welcome content", nil);//@"欢迎使用呱呱试管，呱呱试管是上海祈贝健康管理咨询有限公司旗下的一款专注于试管婴儿服务的软件，公司创立于 2015 年 8 月，是一家移动医疗领域里专注试管婴儿的健康管理咨询公司。公司旨在为国内广大患者和家庭提供一个境内境外做试管婴儿治疗服务的高品质、高标准、专业透明的特色移动医疗服务平台。";
    double profileH=[Tool getHeightByCurrentSize:profileStr withWidth:APPW-kmargin*2 widthHeightLimit:MAXFLOAT withFont:16];
    UILabel *profileLabel=[mainView getLabelWithText:profileStr font:Font_Number(14) textColor:Color666666 textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByTruncatingTail numberOfLines:0];
    [mainView addSubview:profileLabel];
    profileLabel.frame=CGRectMake(kmargin,mainView.frame.size.height,APPW-kmargin*2,profileH);
    setViewHeight_Add(mainView,profileH);

    // 联系方式
    NSString *weixinChat = [NSString stringWithFormat:@"%@: 祈贝孕育",NSLocalizedString(@"Weixin public", nil)];
    NSString *qqChat = [NSString stringWithFormat:@"%@: 3276925976",NSLocalizedString(@"QQ service", nil)];
    NSString *phoneChat = [NSString stringWithFormat:@"%@: 4006175751",NSLocalizedString(@"Service phone", nil)];//.
    NSArray *titleArr=@[weixinChat, qqChat, phoneChat];//@[@"微信公众号: 祈贝孕育",@"客服QQ: 3276925976",@"客服电话: 4006175751"];
    
    for (int i=0;i<titleArr.count;i++)
    {
        UILabel *titLab=[mainView getLabelWithText:titleArr[i] font:Font_Number(14) textColor:Color666666 textAlignment:NSTextAlignmentCenter lineBreakMode:NSLineBreakByTruncatingTail numberOfLines:1];
        titLab.frame=CGRectMake((APPW-200)/2,mainView.frame.size.height+(kmargin*2+kmargin/2)*i+kmargin,200,kmargin*2);//(APPW-150)/2;150;
        [mainView addSubview:titLab];
    }
    setViewHeight_Add(mainView,kmargin*5);
    
//    UIButton *serviceBtn=[UIButton new];
//    [mainView addSubview:serviceBtn];
//    serviceBtn.titleLabel.font=Font_Number(15);
//    serviceBtn.frame=CGRectMake((APPW-100)/2,mainView.frame.size.height+kmargin*6,100,30);
//    [serviceBtn setTitle:@"服务条款" forState:0];
//    [serviceBtn setTitleColor:Main_Color forState:0];
//    [serviceBtn addTarget:self action:@selector(serviceBtnEvent) forControlEvents:UIControlEventTouchUpInside];
//    setViewHeight_Add(mainView,30+kmargin*6);
    
    UILabel *copyRightLabel=[mainView getLabelWithText:NSLocalizedString(@"Shanghai Qibei", nil) font:Font_Number(14) textColor:Color666666 textAlignment:1 lineBreakMode:NSLineBreakByTruncatingTail numberOfLines:0];//@"上海祈贝健康咨询管理有限公司 版权所有";1;
    [mainView addSubview:copyRightLabel];
    copyRightLabel.frame=CGRectMake(kmargin,mainView.frame.size.height+30,APPW-kmargin*2,30+20);
    setViewHeight_Add(mainView,30+kmargin*4);
    

    return mainView;
}

//服务条款
-(void)serviceBtnEvent
{
    ServiceVC *serviceVC=[ServiceVC new];
    [self.navigationController pushViewController:serviceVC animated:NO];
}

-(void)initNavBarBtnItem
{
    self.navigationItem.leftBarButtonItem=[UIBarButtonItem initWithNormalImage:@"back_gray" target:self action:@selector(backItemEvent)];
}

-(void)backItemEvent
{
    [self.navigationController popViewControllerAnimated:NO];
}

@end



